#include "stdafx.h"
//#pragma comment( linker, "/subsystem:console /entry:mainCRTStartup" )
//#pragma comment( linker, "/subsystem:windows /entry:wWinMainCRTStartup" )
//#pragma comment( linker, "/subsystem:windows /entry:wmainCRTStartup" )
// int activex_dll_main(
//         HANDLE  hDllHandle,
//         DWORD   dwReason,
//         LPVOID  lpreserved
//         )
// {
//         if (dwReason == DLL_PROCESS_ATTACH)
//         {
//             /*
//             * The /GS security cookie must be initialized before any exception
//             * handling targetting the current image is registered.  No function
//             * using exception handling can be called in the current image until
//             * after __security_init_cookie has been called.
//             */
//             __security_init_cookie();
//         }
// 
//         return _DllMainCRTStartup(hDllHandle, dwReason, lpreserved);
// }

int activex_main( void )
{
	std::string strDllPath = "C:\\Windows\\SysWOW64\\msvcrt.dll";
	HINSTANCE hDll = LoadLibraryExA(strDllPath.c_str(),NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
	DWORD ErrorNum = GetLastError();
	if( hDll )
	{
		typedef int (*MAINFUN)(void);

		MAINFUN fun = (MAINFUN)::GetProcAddress(hDll, "wmainCRTStartup");
		if( fun )
			return fun();

	}

	return 0;
}